﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using XL = System.Xml.Linq;
using System.Xml.Serialization;
using Dimok;
using Dimok.Shared.Filtering;

namespace Dimok.Shared.Web {
  [DataContract]
  public class UserSettings {
    [DataMember]
    [XmlIgnore]
    internal Dictionary<string, Page> Pages_ { get { return Pages; } }
    public SerializableDictionary<string, Page> Pages = new SerializableDictionary<string, Page>();
    public class Page {
      public Page() { }
      [DataMember]
      public string FontSize;
      [DataMember]
      public System.Drawing.Point Position;
      [DataMember]
      public System.Drawing.Size Size;
      [DataMember]
      [XmlIgnore]
      public Dictionary<string, Grid> Grids_ { get { return Grids; } }
      public SerializableDictionary<string, Grid> Grids = new SerializableDictionary<string, Grid>();
      public class Grid {
        public Grid() { }
        [DataMember]
        public string ActiveRowKey;
        [DataMember]
        public int PageSize;
        [DataMember]
        public string Filter;
        [DataMember]
        public string HideColumns;
        [DataMember]
        public string Sort;
				[DataMember]
				public string Columns;
				[DataMember]
				public string LastReportName;
				[DataMember]
        [XmlIgnore]
        public Dictionary<string, Report> Reports_ { get { return Reports; } }
        public SerializableDictionary<string, Report> Reports = new SerializableDictionary<string, Report>();
        public class Report {
          public Report() { }
          public Report(string Name) {
            this.Name = Name;
          }
          [DataMember]
          public string Name;
					[DataMember]
					public bool? ShowFilter = true;
					[DataMember]
					public bool? ShowTotals = true;
					[DataMember]
					public bool? ShowAverages = true;
					[DataMember]
          public string FilterLinq;
          [DataMember]
          public string Columns;
          [DataMember]
          public string DetailViewXYWH;
          [DataMember]
          public bool IsShared;
					[DataMember]
					public string RadDocks;
					[DataMember]
          [XmlIgnore]
          public Dictionary<string, Dock> Docks_ { get { return Docks; } }
          public SerializableDictionary<string, Dock> Docks = new SerializableDictionary<string, Dock>();
          [DataMember]
          [XmlIgnore]
          public Dictionary<string, Sort> Sorts_ { get { return Sorts; } }
          public SerializableDictionary<string, Sort> Sorts = new SerializableDictionary<string, Sort>();
          [DataMember]
          [XmlIgnore]
          public Dictionary<string, Filter> Filters_ { get { return Filters; } }
          public SerializableDictionary<string, Filter> Filters = new SerializableDictionary<string, Filter>();
          [DataMember]
          [XmlIgnore]
          public Dictionary<string, FilterQuery> FilterQueries_ { get { return FilterQueries; } }
          public SerializableDictionary<string, FilterQuery> FilterQueries = new SerializableDictionary<string, FilterQuery>();
          [DataMember]
          [XmlIgnore]
          public Dictionary<string, Detail> Details_ { get { return Details; } }
          public SerializableDictionary<string, Detail> Details = new SerializableDictionary<string, Detail>();
          public class Dock {
            [DataMember]
            public string Children { get; set; }
            public Dock() { }
            public Dock(string Children) {
              this.Children = Children;
            }
          }
          public class Sort {
            [DataMember]
            public Dimok.Shared.ListSortDirection Order { get; set; }
            public Sort() { }
            public Sort(Dimok.Shared.ListSortDirection Order) {
              this.Order = Order;
            }
          }
          public class Filter {
            [DataMember]
            public string FieldName { get; set; }
            [DataMember]
            public string FieldValue { get; set; }
            [DataMember]
            public string[] FieldValues { get; set; }
            [DataMember]
            public string FilterFunction { get; set; }
            [DataMember]
            public string DataTypeName { get; set; }
            public Filter() { }
            public Filter(string FieldName, string FieldValue, string FilterFunction, string DataTypeName) {
              this.FieldName = FieldName;
              this.FieldValue = FieldValue;
              this.FilterFunction = FilterFunction;
              this.DataTypeName = DataTypeName;
            }
            public Filter(string FieldName, string[] FieldValues, string FilterFunction, string DataTypeName) {
              this.FieldName = FieldName;
              this.FieldValues = FieldValues;
              this.FilterFunction = FilterFunction;
              this.DataTypeName = DataTypeName;
            }

          }
          public class Detail {
            [DataMember]
            public int ColumnPosition { get; set; }
            public Detail() { }
            public Detail(int ColumnPosition) {
              this.ColumnPosition = ColumnPosition;
            }
          }
        }
      }
    }
  }
}
